package com.wit.witmg.api;


import com.wit.witmg.service.ITUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author bob
 * @since 2025-02-24
 */
@RestController
@RequestMapping("user")
@Api(tags = "用户")
public class UserController {
    @Resource
    private ITUserService service;

    @ApiOperation("登录")
    @PostMapping("login")
    public Object login(HttpServletRequest request,@RequestParam("code") String code)
    {
        return service.login(request,code);
    }

    @ApiOperation("绑定手机号")
    @PostMapping("bindPhone")
    public Object bindPhone(HttpServletRequest request,
                            @RequestParam("code") String code) {
        return service.bindPhone(request,code);
    }

    @ApiOperation(value = "App端登录", notes = "根据code获取openid和用户信息。")
    @PostMapping("loginApp")
    public Object loginApp(HttpServletRequest request,@RequestParam("code") String code) {
        return service.loginApp(request,code);
    }

    @ApiOperation("添加/修改")
    @PostMapping("add")
    public Object add(HttpServletRequest request,
                      @RequestParam("json") String json) {
        return service.add(request,json);
    }

}
